﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class UserControls_UserAccCtl : xIx.Web.UI.ControlBase
{
    public string Groups
    {
        get
        {
            object v = ViewState["Groups"];
            if (null != v)
            {
                return (string)v;
            }
            else
            {
                return default(string);
            }
        }
        set
        {
            ViewState["Groups"] = value;
        }
    }
    public string Roles
    {
        get
        {
            object v = ViewState["Roles"];
            if (null != v)
            {
                return (string)v;
            }
            else
            {
                return default(string);
            }
        }
        set
        {
            ViewState["Roles"] = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        if (!checkctl()) {
            Page.SetPageDisable();
        }
    }
    public bool checkctl() { 
    
        if(Groups=="*" && Roles=="*")return true;
        if(Page.User==null)return false;
        if(!(Groups=="*"|| Groups.IndexOf( Page.User.AccountInfo.InstituteLevel.ToString())!=-1||Groups.IndexOf(Page.User.AccountInfo.InstituteLevelName)!=-1))return false;
        if(!(Roles=="*"||(","+Roles+",").IndexOf(","+Page.User.AccountInfo.Role+",")!=-1))return false;
        return true;
    }
}
